package utils

import (
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
)

/*
 * 跨域配置
 */
func RequestCORS() echo.MiddlewareFunc {
	return middleware.CORSWithConfig(middleware.CORSConfig{
		AllowOrigins: []string{"*"},
		AllowHeaders: []string{"Origin", "No-Cache", "X-Requested-With", "If-Modified-Since",
			"Pragma", "Last-Modified", "Cache-Control", "Expires", "Content-Type", "X-E4M-With",
			"Authorization", "Coconut-Token", "X-Token"},
		AllowCredentials: true,
		AllowMethods:     []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE},
	})
}
